package com.szliang.threadlocal;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 描述：两个线程打印日期
 */
public class ThreadLocalNormalUsage00 {

    public static void main(String[] args) {
        new Thread(() -> {
                String date = new ThreadLocalNormalUsage00().date(1000);
                System.out.println(date);
            }
        ).start();

        new Thread(() -> {
            String date = new ThreadLocalNormalUsage00().date(10007);
            System.out.println(date);
        }
        ).start();
    }

    public String date(int seconds) {
        //参数单位是毫秒 从1970.1.1 08:00:00 GMT计时（东8区）
        Date date = new Date(seconds*1000);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = dateFormat.format(date);
        return format;
    }
}
